﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace MuggleTactics
{
    class Piece : Microsoft.Xna.Framework.DrawableGameComponent
    {
        // Class variables
        string name;
        public string texturePath = "Images/Harry_Potter_sprite";
        Texture2D textureImage;
        Vector2 position;
        public Point currentFrame;
        Point frameSize;
        public Point sheetSize;
        public const int milliSecondsPerFrame = 250;

        // Fix animation handler
        // Test
        public enum FaceDirection
        {
            FACE_UP,
            FACE_RIGHT,
            FACE_DOWN,
            FACE_LEFT
        }

        public FaceDirection faceDirection;

        public Piece(Game game, Texture2D textureImage, Vector2 position,
            Point currentFrame, Point frameSize, Point sheetSize)
            :base(game)
            //: this(textureImage, position, currentFrame, frameSize)
        {
            setTexture(textureImage);
            setPosition(position);
            setCurrentFrame(currentFrame);
            setFrameSize(frameSize);
            setSheetSize(sheetSize);
        }

        public Piece(Game game)
            :base(game)
        {
        }

        // Class Setters
        public void setPosition(Vector2 position) { this.position = position; }
        public void setName(string name) { this.name = name; }
        public void setTexture(Texture2D textureImage) { this.textureImage = textureImage; }
        public void setCurrentFrame(Point currentFrame) { this.currentFrame = currentFrame; }
        public void setFrameSize(Point frameSize) { this.frameSize = frameSize; }
        public void setSheetSize(Point sheetSize) { this.sheetSize = sheetSize; }
        public void setFaceDirection(FaceDirection faceDirection) { this.faceDirection = faceDirection; }

        // Class Getters
        public Texture2D getImage() { return this.textureImage; }
        public string getName() {return this.name;}

        public Vector2 getPosition
        {
            get
            {
                return position;
            }
        }
        public virtual void Update(GameTime gameTime, Rectangle clientBounds)
        {

        }

        public virtual void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(textureImage, position, new Rectangle(
                currentFrame.X * frameSize.X,
                currentFrame.Y * frameSize.Y,
                frameSize.X, frameSize.Y),
                Color.White);
        }

    }
}
